$(function () {
    $('form').on('submit', function (e) {
        e.preventDefault();
        var data = $(this).serialize();
        $.ajax({
            type: 'post',
            url: 'api/login',
            data: data,
            success: function (a) {
                layer.msg(a.message);
                if (a.status === 0) {
                    $('form')[0].reset();
                }
            }
        })
    });
    $('form').on('submit', function (e) {
        e.preventDefault();
        var data = $(this).serialize();
        $.ajax({
            type: 'post',
            url: 'api/login',
            data: data,
            success: function (a) {
                if (a.status === 0) {
                    localStorage.setItem('mytoken', a.token);
                    location.href = './index.html';
                }
            }
        })
    })
})